package com.syg.exception;

import com.syg.boot.exception.IExceptionCode;

/**
 * @author ps
 */
public abstract class BaseException extends RuntimeException{
    private final IExceptionCode code;
    private final String codeMsg;

    public BaseException(IExceptionCode code) {
        super((String)code.getValue() + "----" + code.getMessage());
        this.code = code;
        this.codeMsg = code.getMessage();
    }

    public BaseException(IExceptionCode code, String... params) {
        super((String)code.getValue() + "----" + code.getMessage());
        this.code = code;
        this.codeMsg = params.toString();
    }

    public BaseException(IExceptionCode code, String message) {
        super((String)code.getValue() + "----" + code.getMessage());
        this.code = code;
        this.codeMsg = message;
    }

    public BaseException(IExceptionCode code, Throwable throwable) {
        super((String)code.getValue() + "----" + code.getMessage(), throwable);
        this.code = code;
        if (null == throwable && null != code) {
            this.codeMsg = code.getMessage();
        } else if (null != throwable) {
            this.codeMsg = throwable.getMessage();
        } else {
            this.codeMsg = null;
        }

    }
}
